#!/bin/bash

# download is part of qorgboot.

# qorgboot is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# qorgboot is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with qorgboot.  If not, see <https://www.gnu.org/licenses/>.

if [ -z "$1" ]
then
    echo "download";
    echo "$0 all -- Download everything"
    echo "$0 flashrom -- Download flashrom"
    echo "$0 coreboot -- Download coreboot";
    exit;
fi

if test -f "/usr/bin/git"; then

    if [ "$1" = 'flashrom' ];
    then
        git clone https://review.coreboot.org/flashrom.git srcs/flashrom
        echo "Flashrom downloaded";

    fi
    if [ "$1" = "all" ];
    then
        git clone https://review.coreboot.org/coreboot.git srcs/coreboot --depth=4
        git clone https://review.coreboot.org/flashrom srcs/flashrom
        git clone https://notabug.org/qorg11/ich9gen srcs/ich9gen
    fi
    if [ "$1" = "coreboot" ];
    then
        git clone https://review.coreboot.org/coreboot.git srcs/coreboot --depth=4
    fi
    if [ "$1" = "ich9gen" ];
    then
	git clone https://notabug.org/qorg11/ich9gen srcs/ich9gen
    fi
    
    
else
    echo "Install git."
    exit;
fi
